<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" %>
<%@ include file="/resources/modular/plugin/taglibs.jsp" %>
<!doctype html>
<head content="-我的">
    <%@ include file="/resources/modular/head/inside_head.jsp" %>
    <style type="text/css">
        .pointpage_dv1, .pointpage_dv2,
        .pointpage_dv3, .pointpage_dv4,
        .my_childAccount_managedv, .my_childAccount_pointpage,
        .my_childAccount_addchildrendv {
            display: none;
        }

        .my_childAccount_pointpagedv_ul ul {
            display: none;
        }

        .my_childAccount_pointpagedv_ul > li > p, .my_childAccount_pointpagedv_rightul > li > p {
            text-indent: 20px;
            line-height: 40px;
            color: #666;
            border-bottom: 1px solid #eee;
        }

        .my_childAccount_addBtn, .my_childAccount_removeBtn {
            display: none;
            font-style: normal;
        }

        .my_childAccount_pointpagedv_left .my_childAccount_removeBtn {
            display: inline;
            color: #f00;
            font-size: 14px;
        }

        .my_childAccount_pointpagedv_right .my_childAccount_addBtn {
            display: inline;
            color: #38adff;
            font-size: 14px;
        }

    </style>
</head>
<body class="GC_Menu_7" name="GC_indvidual">

<%@ include file="/resources/modular/plugin/mainMenu.jsp" %>

<div class="page" name="GC_individual_childuserinfo">

    <%@ include file="/resources/modular/plugin/mainTopMenu.jsp" %>

    <%@ include file="/resources/modular/plugin/individualMeun.jsp" %>

    <div class="page_right">
        <%--<div class="my_childAccount_page">
            <p class="my_childAccount_pagep2"><a href="javascript:" onclick="self.location=document.referrer;">返回</a>
            </p>
        </div>--%>

        <div class="my_childAccount_pointpage" style="display:block;">
            <p class="my_childAccount_pointpagep1">角色名称：<input id="GC_addusergroup_usergroupname" type="text"
                                                               placeholder="请输入需要添加的角色名称"></p>
            <div class="my_childAccount_pointpagedv">
                <div class="my_childAccount_pointpagedv_left">
                    <p class="my_childAccount_pointpagep2">已选授权名称</p>
                    <ul class="my_childAccount_pointpagedv_ul" id="GC_USEDMODULES">

                    </ul>
                </div>

                <div class="my_childAccount_pointpagedv_right">
                    <p class="my_childAccount_pointpagep2">可选授权名称</p>
                    <ul class="my_childAccount_pointpagedv_ul">
                        <%--一级目录 开始--%>
                        <c:forEach items="${modules}" var="module" varStatus="perentStatus">
                            <li>
                                <p class="my_childAccountId_${perentStatus.index}">
                                    <span class="my_childAccount_name" GC_ROLEMODULE="${module.id}">${module.text}（可选择）</span>
                                    <a href="javascript:;"><var class="my_childAccount_addBtn">全部添加</var><var
                                            class="my_childAccount_removeBtn">全部删除</var></a>
                                </p>
                                <ul class="">
                                        <%--二级目录 开始--%>
                                    <c:forEach items="${module.children}" var="levelChildren2"
                                               varStatus="levelChildren2Status">
                                        <li>
                                            <p class="my_childAccountId_${perentStatus.index}_${levelChildren2Status.index}"><span
                                                    class="my_childAccount_name" GC_ROLEMODULE="${levelChildren2.id}">${levelChildren2.text}</span><a
                                                    href="javascript:;"><var
                                                    class="my_childAccount_removeBtn">删除</var><var
                                                    class="my_childAccount_addBtn">添加</var></a></p>
                                            <ul class="">
                                                    <%--三级目录 开始--%>
                                                <c:forEach items="${levelChildren2.children}" var="levelChildren3"
                                                           varStatus="levelChildren3Status">
                                                    <li>
                                                        <p class="my_childAccountId_${perentStatus.index}_${levelChildren2Status.index}_${levelChildren3Status.index}"><span
                                                                class="my_childAccount_name" GC_ROLEMODULE="${levelChildren3.id}">${levelChildren3.text}</span><a
                                                                href="javascript:;"><var
                                                                class="my_childAccount_removeBtn">删除</var><var
                                                                class="my_childAccount_addBtn">添加</var></a></p>
                                                        <ul class="">

                                                            <c:forEach items="${levelChildren3.children}"
                                                                       var="levelChildren4"
                                                                       varStatus="levelChildren4Status">
                                                                <li>
                                                                    <p class="my_childAccountId_${perentStatus.index}_${levelChildren2Status.index}_${levelChildren3Status.index}_${levelChildren4Status.index}">
                                                                        <span GC_ROLEMODULE="${levelChildren4.id}">${levelChildren4.text}</span><a
                                                                            href="javascript:;"><var
                                                                            class="my_childAccount_removeBtn">删除</var><var
                                                                            class="my_childAccount_addBtn">添加</var></a>
                                                                    </p></li>
                                                            </c:forEach>
                                                        </ul>
                                                    </li>
                                                </c:forEach>
                                                    <%--三级目录 结束--%>
                                            </ul>
                                        </li>
                                    </c:forEach>
                                        <%--二级目录 结束--%>
                                </ul>
                            </li>

                        </c:forEach>
                        <%--一级目录 结束--%>
                    </ul>
                </div>
            </div>
            <p class="my_childAccount_pointpagep3"><a class="my_childAccount_addchildbtn3" href="javascript:;">确认</a> <a
                    class="my_childAccount_addchildbtn4" href="javascript:history.go(-1);" onclick="self.location=document.referrer;">取消</a>
            </p>
        </div>

    </div>

</div>

</body>
</html>
<%@ include file="/resources/modular/foot/inside_footer.jsp" %>
<script type="text/javascript" src="${basePath}resources/js/v2/improve.js"></script>
<script type="text/javascript">

    var modulesArray=[];

    $("#test").click(function () {
        $.ajax({
            url: '${basePath}v2/individual/showaddusergroup',
            type: 'GET',
            error: function (response) {
                $errorMsg(response);
            },
            success: function (ret) {
                console.dir(ret);
            }
        });
    });

    <%-- 新增子角色 --%>
    $(".my_childAccount_addchildbtn3").click(function () {

        $("#GC_USEDMODULES span").each(function(index,obj){
            modulesArray[index]=$(obj).attr("GC_ROLEMODULE");
        })

        var usergroupname = $("#GC_addusergroup_usergroupname").val();
        if (typeof(usergroupname) == "undefined" || usergroupname.length <= 0) {
            alert("角色名称不能为空");
        } else {
            $.ajax({
                url: '${basePath}v2/individual/addusergroup',
                type: 'POST',
                data: {
                    "usergroupname": usergroupname,
                    "modules":modulesArray
                },
                traditional: true,
                error: function (response) {
                    $errorMsg(response);
                },
                success: function (ret) {
                    if (ret.result) {
                        window.location.href = document.referrer;
                    } else {
                        alert(ret.info);
                    }
                }
            });
        }
    });

</script>
